﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gnosis.Alexandria.Model.Commands
{
    public class SelectByNameOrHash
        : CommandBuilderBase
    {
        public SelectByNameOrHash(string search)
            : base(null)
        {
            if (string.IsNullOrEmpty(search))
                throw new ArgumentException("Search cannot be null or an empty string");

            var hash = NamedHashedBase.GetHash(search);

            Append("SELECT * FROM Artist WHERE Name LIKE @Name OR Hash LIKE @Hash;");
            AddParameter("Name", string.Format("%{0}%", search));
            AddParameter("Hash", string.Format("%{0}%", hash));
        }
    }
}
